﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Algorithm_api.calculate.BranchBound
{
    public class BranchBound
    {
        public int N { get; set; }
        public int K { get; set; }
        public int[] Array { get; set; } 
        public int[] List { get; set; }
        public int result { get; set; } = 9999999;

        
        public void dfs(int n,int k)
        {
            if (result <= k) return; //剪枝
            if(n == N)
            {
                if (result > k) result = k;
                return;
            }

            for(int i = 0; i < K; i++)  //循环机器
            {
                if(List[i] + Array[n] < result)
                {
                    List[i] = List[i] + Array[n];
                    dfs(n + 1, Math.Max(k, List[i]));
                    List[i] = List[i] - Array[n]; //回溯
                }
            }
        }

        
    }
}
